/**公共提示信息*/
OA_FRIST_MAIN="已经是本页第一封了";
OA_LAST_MAIN="已经是本页最后一封了";


//菜单点击
var menlinkClick = function(link){
	if(link){
		try{
			CQOA.loadMain(link,{},function(){
				
			});
		}catch (e) {
			unmask();
			console.log(e);
		}
	}
};


function showHideFun(target, status) {
	$("#" + target).window(status);
};
/**下载附件*/
var downloadFun = function(val){
	commonOpenWin(ctx+'/sm/File!download.action?entity.sid='+val,800,600);
};

var download = function(name,ids){
	commonOpenWin(ctx+'/sm/File!download.action?entity.targetTableName='+name+'&entity.targetTableSid='+ids,800,600);
};
/**删除附件*/
var deleteFile = function(val,callback){
	postcommit(ctx+'/sm/File!delete.action?entity.sid='+val,{},callback);
};

var commonOpenWin =function(url, width, height, style) {
	if (style == null) {
		style = "resizable=1,directories=0,location=0,menubar=0,scrollbars=1,status=0,titlebar=0,toolbar=0";
	}
	if (height != null) {
		style = "height=" + height + "," + style;
		var top = Math.round((screen.availHeight - height) / 2);
		style = "top=" + top + "," + style;
	}
	if (width != null) {
		style = "width=" + width + "," + style;
		var left = Math.round((screen.availWidth - width) / 2);
		style = "left=" + left + "," + style;
	}
	return window.open(url, "", style);
};

/**
 * post 提交 数据
 */
var postcommit = function(url,param,callback){
	 $.post(url, param, function(data, status) {
         if (callback) {
             callback(data, status);
         }
     }, 'json');
};

//处理键盘事件 禁止后退键（Backspace）密码或单行、多行文本框除外  
function banBackSpace(e){     
    var ev = e || window.event;//获取event对象     
    var obj = ev.target || ev.srcElement;//获取事件源     
    var t = obj.type || obj.getAttribute('type');//获取事件源类型    
    //获取作为判断条件的事件类型  
    var vReadOnly = obj.getAttribute('readonly');  
    var vEnabled = obj.getAttribute('enabled');  
    if('readonly'==vReadOnly){
    	vReadOnly = true;
    }
    //处理null值情况  
    vReadOnly = (vReadOnly == null) ? false : vReadOnly;  
    vEnabled = (vEnabled == null) ? true : vEnabled;  
    //当敲Backspace键时，事件源类型为密码或单行、多行文本的，  
    //并且readonly属性为true或enabled属性为false的，则退格键失效  
    var flag1=(ev.keyCode == 8 && (t=="password" || t=="text" || t=="textarea")   
                && (vReadOnly==true || vEnabled!=true))?true:false;  
     
    //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效  
    var flag2=(ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea")  
                ?true:false;          
      
    //判断  
    if(flag2){  
        return false;  
    }  
    if(flag1){     
        return false;     
    }     
}; 
